import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart';
import '../../../app_files.dart';
import 'action.dart';
import 'state.dart';

Widget buildView(
    EditViewState state, Dispatch dispatch, ViewService viewService) {
  return Scaffold(
    backgroundColor: Colors.transparent,
    body: Column(
      children: <Widget>[
        Expanded(
          child: InkResponse(
              highlightColor: Colors.transparent,
              radius: 0.0,
              child: Container(),
              onTap: () {
                state.commentFocus.unfocus();
                Navigator.pop(viewService.context);
              }),
        ),
//
        Container(
          padding: const EdgeInsets.only(bottom: 14),
          color: const Color(0xFFF8F8F8),
          child: SafeArea(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.end,
              children: <Widget>[
                Padding(
                  padding: const EdgeInsets.only(
                      left: 16, top: 14, bottom: 14, right: 20),
                  child: Stack(
                    children: [
                      Center(
                        child: Text(
                          state.title,
                          style: TextThemeConfig.Font16BoldWithColor22,
                        ),
                      ),
                      Positioned(
                        left: 3,
                        top: 3,
                        child: state.isDel
                            ? MyInkWellWidget(
                                child: const Text(
                                  '删除',
                                  style: TextThemeConfig.Font16WithColor22,
                                ),
                                onTap: () => Navigator.pop(
                                    viewService.context, 'isDeLLt'),
                              )
                            : MyInkWellWidget(
                                child: const Text(
                                  '取消',
                                  style: TextThemeConfig.Font16WithColor22,
                                ),
                                onTap: () => Navigator.pop(viewService.context),
                              ),
                      ),
                      Positioned(
                        right: 3,
                        top: 3,
                        child: MyInkWellWidget(
                          child: const Text(
                            '完成',
                            style: TextThemeConfig.Font16WithMainColor,
                          ),
                          onTap: () {
                            Navigator.pop(
                              viewService.context,
                              state.controller.text,
                            );
                          },
                        ),
                      ),
                    ],
                  ),
                ),
                Container(
                  padding: const EdgeInsets.only(left: 8, right: 6),
                  color: Colors.white,
                  child: TextField(
                    controller: state.controller,
                    keyboardType: state.inputType,
                    minLines: 1,
                    maxLines: state.maxLines,
                    autofocus: true,
                    focusNode: state.commentFocus,
                    style:
                        const TextStyle(color: Color(0xFF222222), fontSize: 14),
                    decoration: InputDecoration(
                      border: InputBorder.none,
                      hintText: state.desc,
                      hintStyle:
                          const TextStyle(color: Colors.grey, fontSize: 14),
                      contentPadding: const EdgeInsets.only(bottom: 3, top: 0),
                    ),
                    onSubmitted: (_) {
                      Navigator.pop(
                        viewService.context,
                        state.controller.text.isNotEmpty
                            ? state.controller.text
                            : null,
                      );
                    },
                  ),
                ),
              ],
            ),
          ),
        ),
      ],
    ),
  );
}
